package day16.ArgsDemo;

public class ArgsDemo<T> {
    public static void main(String[] args) {
        //求和
        Integer result = 0;
        result = getResult(10, 20);
        System.out.println(result);

        result = getResult(10, 20, 30);
        System.out.println(result);

        result = getResult(10, 20, 30, 40);
        System.out.println(result);

        result = getResult(10, 20, 30, 40, 50);
        System.out.println(result);
    }

    public static int getResult(int... a) {
        int result = 0;

        for (int temp : a) {
            result += temp;
        }
        return result;
    }
}
